package cn.com.haopy.yue.ai.db.service.hos.impl;

import cn.com.haopy.yue.ai.db.entity.arisk.AIRiskIllnessDrugs;
import cn.com.haopy.yue.ai.db.mapper.arisk.AIRiskIllnessDrugsMapper;
import cn.com.haopy.yue.ai.db.service.BaseServiceImpl;
import cn.com.haopy.yue.ai.db.service.hos.AIRiskIllnessDrugsService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: TODO
 * @Author DuTao
 * @Date 2025/5/6 14:15
 */
@Service
public class AIRiskIllnessDrugsServiceImpl extends BaseServiceImpl<AIRiskIllnessDrugsMapper, AIRiskIllnessDrugs> implements AIRiskIllnessDrugsService {
    @Override
    public IPage<AIRiskIllnessDrugs> querySelective(String drugName, Integer illnessId, Integer pageNum, Integer pageSize) {
        Page<AIRiskIllnessDrugs> page = new Page<>(pageNum, pageSize);
        return baseMapper.selectWithDrugName(page, drugName, illnessId);
    }

    @Override
    public List<AIRiskIllnessDrugs> getByName(Integer illnessId, String drugName) {
        QueryWrapper<AIRiskIllnessDrugs> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(AIRiskIllnessDrugs::getIllnessId, illnessId);
        queryWrapper.lambda().eq(AIRiskIllnessDrugs::getDrugName, drugName);
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public List<AIRiskIllnessDrugs> getByIllnessId(Integer illnessId) {
        QueryWrapper<AIRiskIllnessDrugs> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(AIRiskIllnessDrugs::getIllnessId, illnessId);
        return baseMapper.selectList(queryWrapper);
    }
}
